#! bash

##########################################################

myset(){

##echo "************ myset() ************"

export LS_COLORS=$LS_COLORS":*.C=01;31"
export LS_COLORS=$LS_COLORS":*.cxx=01;31"

#directory 
#export LS_COLORS=$LS_COLORS":di=00;94" 

alias rm='rm -i'
alias mv='mv -i'
alias cp='cp -i'
alias ls00='ls --color=tty -lh'
alias ls0='ls --color=tty -lhXB'
alias ls='ls --color=tty -lhtB'
alias mkdir='mkdir -p'
alias r='root -l'
alias mydu='du -scm * | sort -n'
#alias top='top -u xlu'
alias ps='ps -f -u $(whoami)'
alias e='emacs'
enwr() {
  emacs "$1" -nw --eval '(setq buffer-read-only t)'
}

export OX="luxi@pplxint9.physics.ox.ac.uk"
alias ox='ssh -X $OX'

export HD="lu@pi0.physi.uni-heidelberg.de"
alias hd='ssh -X $HD'

export GSI="xlu@lxi001.gsi.de"
alias gsi='ssh -X $GSI'

#ps -f -u $(whoami)

##echo 
##echo "^(-_-)^!!"
##echo

serv=$(uname -n)

}

homedu(){
    ##echo "************ homedu() ************"
    du -scm $(ls -a | awk '{print $9"#"}' | grep -v "\.\#" | awk -F\# '{print $1}') | sort -n
}

##########################################################

setCode(){
##echo "************ setCode() ************"

export myHOME=~/.localsvn/code
export myINC=$myHOME/inc
export mySRC=$myHOME/src
export myBIN=$myHOME/bin

#export myAliROOT=$mySRC/myAliROOT

export mySVN="https://alixglutils.googlecode.com/svn/trunk"
export SVN_EDITOR="emacs -nw"
alias ggc='echo HT7An6Gq4An6'

#important for checkcode not working, need path
export PATH=$myBIN:$PATH

#important for alien libssl ect.
#export LD_LIBRARY_PATH=
#/usr/lib64/:$ALICE/myalien/lib/:$LD_LIBRARY_PATH

}

setROOT(){
    for ii in $(echo /home/xlu/workspace/software /data/t2k/xlu/software)
    do
        if [ -e $ii ]
        then
            
MJ=`grep -c bogomips /proc/cpuinfo 2> /dev/null`
[ "$?" != 0 ] && MJ=`sysctl hw.ncpu | cut -b10 2> /dev/null`
# If MJ is NaN, "let" treats it as "0": always fallback to 1 core
let MJ++
export MJ


export SOFTWARE_PREFIX=$ii
export ROOT_VER=inuse
#v5-34-21
#v5-34-14
export ROOTSYS=${SOFTWARE_PREFIX}/root/${ROOT_VER}

export PATH=$PATH:$ROOTSYS/bin 
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ROOTSYS/lib

export GINC="\
-I$ROOTSYS/include \
"

export GLIB="\
$(root-config --libs) -lMinuit -lEG -lGeom -lVMC -lProof -lProofPlayer -lXMLParser -lXMLIO -lSpectrum -lTreePlayer -lMLP -lGui \
"

#CDB <- Gui
#STEER <- Minuit EG Geom VMC Proof ProofPlayer XMLParser,  RAWDatarec ESD STEERBase ANALYSIS RAWDatabase 
#ANALYSISalice <- XMLIO TreePlayer, AOD
#TPCrec <- Spectrum, TPCbase 
#TRDrec <- MLP, TRDbase STAT 

export myGCC="-g -O3 -Wall -Werror \
$GINC $GLIB \
-I$myINC \
"

#-I$ALICE_ROOT/XGLUtils -lXGLUtils \

        fi
    done

}


##########################################################
##########################################################

SetOxford(){

##echo "************ SetOxford() ************"

place="Oxford"

alias cd1='cd /data/t2k/xlu/'
alias cdpx='cd /data/t2k/xlu/software/t2k/nd280/highland2/numuCCPXAnalysis/v0r0'

}

SetGSI(){

##echo "************ SetGSI() ************"

place="GSI"

#alias cd1='cd /d/alice11/xlu'
#alias cdl='cd /lustre/alice/xlu'
alias cdh='cd /hera/alice/xlu'

alias g35='ssh -X lxi035'
alias g37='ssh -X lxi037'
alias g39='ssh -X lxi039'
alias g41='ssh -X lxi041'
alias g43='ssh -X lxi043'
alias g47='ssh -X lxi047'
alias g49='ssh -X lxi049'

alias gnew='ssh -X squeezelust64'
alias g54='ssh -X lxi054'
alias g55='ssh -X lxi055'
alias g56='ssh -X lxi056'
alias g57='ssh -X lxi057'
alias g58='ssh -X lxi058'
alias g59='ssh -X lxi059'
alias g60='ssh -X lxi060'

alias gb6='ssh -X lxb666'
alias gb7='ssh -X lxb667'
alias gb8='ssh -X lxb668'
alias gb9='ssh -X lxb669'

alias gs1='ssh -X lxsub01'
alias gs2='ssh -X lxsub02'
alias gs3='ssh -X lxsub03'
alias gs4='ssh -X lxsub04'

###

export EDIR=~/mytools/emacs-23.3/
alias e=$EDIR/src/emacs

}

##########################################################
##########################################################

##echo
##echo
##echo
##echo "Starting personal configuration for $(whoami) ..."
##echo
##echo 

myset

if [ ${serv:0:3} == "ppl"  ]
then
    SetOxford
elif [ ${serv:0:2} == "lx"  ]
then
    SetGSI
fi

setCode
#tmptest
#setROOT

##echo 
##echo "           Orz @ "$place $serv
##echo 
